<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<jsp:useBean id="member" class="oneroom.admin.member.MemberDao" scope="page"/>
<jsp:useBean id="code" class="oneroom.admin.code.codeDao" scope="page"/>
<%@ page import="oneroom.admin.member.MemberModel" %>
<%@ page import="oneroom.admin.code.codeModel" %>
<%@ page import="java.util.ArrayList"%>
<%@ page import="java.util.HashMap"%>
<%@ page import="java.util.List" %>
<%
	String redirectUrl = "";
	if (session.getAttribute("id") != null &&
			((String)session.getAttribute("id")).equals("") == false) {
	} else {
		redirectUrl = "/room/member/login.jsp";
		response.sendRedirect(redirectUrl);
	}
	HashMap	paramMap = new HashMap();
	String	id				= (String)session.getAttribute("id") == null ? "" : (String)session.getAttribute("id");
	
	paramMap.put("id",id);
	ArrayList returnList	=  member.getView(paramMap);
	MemberModel model	= new MemberModel();
	List list1 = code.getDtlList("100");
	List list2 = code.getDtlList("101");
	if(returnList != null && returnList.size() > 0){
		model = (MemberModel)returnList.get(0);		
	}
	
	String mode = request.getParameter("mode") == null ? "I" : request.getParameter("mode");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>원룸몬스터</title>

<link href="/room/css/all.css" rel="stylesheet" type="text/css" />
<script src="/room/script/swfobject_modified.js" type="text/javascript"></script>
<script src="/room/script/common.js" type="text/javascript"></script>
<script src="/room/script/default.js" type="text/javascript" ></script>
<script src="/room/script/jquery-1.3.2.min.js" type="text/javascript" ></script>
<script type="text/javascript">
<!--
var id = "";
$(document).ready(function(){
	
  
	$('#email2').change(function(){
	var val = $('#email2 > option:selected').val();
		if(val == ''){
	      $('#email3').show();
		}else{
		  $('#email3').hide();
		}    
	});  
	
});
	function chkPassword(){
		  var obj = document.getElementById("pwd");
		  if(obj.value.search(/[^a-zA-Z0-9-_]/g) != -1){
		    alert('영문이나 숫자만 입력하실 수 있습니다');
		    obj.value = '';
		    return false;
		  }  
		  return true;
	}
		
	function chechk(){
		if($("#id").val() == "" ){
			alert("ID을 입력하세요.");
			return false;
		}else if($("#name").val() == ""){
			alert("이름을 입력하세요.");
			return false;
		}else if($("#pwd").val() == "" ){
			alert("비밀번호을 입력하세요.");
			return false;
		}else if($("#repwd").val() == ""){
			alert("비밀번호확인을 하세요.");
			return false;
		}else if($("#pwd").val() != $("#repwd").val()){
			alert("비밀번호확인을 하세요.");
			return false;
		}else if($("#tel1").val() == "" && $("#tel2").val() == "" && $("#tel3").val() == "" ){
			alert("전화번호를 입력하세요.");
			return false;
		}else if($("#hp1").val() == "" && $("#hp2").val() == "" && $("#hp3").val() == "" ){
			alert("전화번호를 입력하세요.");
			return false;
		}else if($("#email1").val() == "" && ($("#email2").val() == "" || $("#email3").val() == "") ){
			alert("E-mail를 입력하세요.");
			return false;
		}else if($("#email2").val() == "" ){
			alert("E-mail를 입력하세요.");
			return false;
		}else if(!isEng($("#email1").val())){
			alert("영문숫자만 가능합니다.");
			return false;
		}else if(!isEng($("#pwd").val())){
			alert("영문숫자만 가능합니다.");
			return false;
		}else{
			return true;
		}
	}
	
//-->
</script>
</head>

<body>
<div align="center"> 

 <div id="content">

<!----------------왼쪽---------------->  
<%@ include file="/room/common/left.jsp" %>
<!----------------왼쪽끝---------------->  


<!----------------가운데 시작----------------> 
<form name="frm" id="frm" action="dbx.jsp" method="post" onsubmit="return chechk();" >
<input type="hidden" name="mode" value="U" />
<input type="hidden" name="id" value="<%=id%>" />
 <div id="rgt">
  <div id="con01">
   <div class="top bb1"><img src="/room/img/txt_top.gif" /></div> 
   <div>
    <div class="list h550">
      <div class="pb20"><span style="font-size:11px;">Home >회원> <span style="color:#000;">정보수정</span></span></div>
      <div>
       <div class="pb10"><img src="/room/img/line_blue.gif" width="32" height="2" /></div>
       <div class="tit">정보 수정 </div>
     </div>
     <div><span style="font-size:11px;">홈페이지에 오신 여러분 환영합니다.</span></div>
     
     <div style="width:595px;" align="right"><a href="update.jsp"><img src="/room/img/tab_edit.gif"/></a><a href="delete.jsp"><img src="/room/img/tab_out_off.gif"hspace="5" /></a></div>
     
     <div class="pt10 pb10"><span style="font-size:11px;"><strong>*항목은 필수 입력항목입니다.</strong></span></div>
    <table width="595" border="0" cellspacing="0" cellpadding="0">
<col width="135px" />
<col width="90px" />
<col width="90px" />
<col width="80px" />
<col width="205px" />

  <tr>
    <td class="ac fw bt2 bb1 h30 bg_g">*이름</td>
    <td colspan="4" class="bt2 bb1 h30 pl10 "><%=model.getName() %></td>
    </tr>
  
  <tr>
    <td class="ac fw bb1 h30 bg_g">* ID</td>
    <td  colspan="4" class=" bb1 h30 pl10">
    	<input name="" id="" value="<%=model.getId() %>" title="아이디" type="text" maxlength="12" style="width:150px;" disabled="disabled" />
	</td>
    </tr>
  <tr>
    <td class="ac fw bb1 h30 bg_g">* 비밀번호
</td>
    <td colspan="4" class=" bb1 h30 pl10"><input name="pwd" id="pwd" value="<%=model.getPwd() %>" title="비밀번호" type="password" /><span style="font-size:11px;"> &nbsp;&nbsp;6~12자 이내, 영문, 숫자, 특수문자 조합</span> </td>
    </tr>
  <tr>
    <td class="ac fw bb1 h30 bg_g">* 비밀번호 확인</td>
    <td colspan="4" class=" bb1 h30 pl10"><input name="repwd" id="repwd" value="" title="비밀번호확인" type="password" /> <span style="font-size:11px;">&nbsp;&nbsp;비밀번호를 한번 더 적어 주세요.</span>
</td>
  </tr>
  <tr>
    <td class="ac fw bb1 h30 bg_g">* 전화</td>
<%	
	if(!model.getTel().equals("")){
		if(model.getTel().startsWith("02")){
%>    
	<td class=" bb1 h30 pl10">
    <select style="width:70px;" name="tel1" id="tel1">
	    <option value="02" selected="selected">02</option>
	    <option value="031">031</option>
	    <option value="032">032</option>
	    <option value="033">033</option>
	    <option value="041">041</option>
	    <option value="042">042</option>
	    <option value="043">043</option>
	    <option value="051">051</option>
	    <option value="052">052</option>
	    <option value="053">053</option>
	    <option value="054">054</option>
	    <option value="055">055</option>
	    <option value="061">061</option>
	    <option value="062">062</option>
	    <option value="063">063</option>
	    <option value="064">064</option>
    </select>
<%
		}else{
%>
	<td class=" bb1 h30 pl10">
    <select style="width:70px;" name="tel1" id="tel1">
	    <option value="02">02</option>
	    <option value="031" <%if(model.getTel().substring(0,3).equals("031")){%>selected="selected"<%}%>>031</option>
	    <option value="032" <%if(model.getTel().substring(0,3).equals("032")){%>selected="selected"<%}%>>032</option>
	    <option value="033" <%if(model.getTel().substring(0,3).equals("033")){%>selected="selected"<%}%>>033</option>
	    <option value="041" <%if(model.getTel().substring(0,3).equals("041")){%>selected="selected"<%}%>>041</option>
	    <option value="042" <%if(model.getTel().substring(0,3).equals("042")){%>selected="selected"<%}%>>042</option>
	    <option value="043" <%if(model.getTel().substring(0,3).equals("043")){%>selected="selected"<%}%>>043</option>
	    <option value="051" <%if(model.getTel().substring(0,3).equals("051")){%>selected="selected"<%}%>>051</option>
	    <option value="052" <%if(model.getTel().substring(0,3).equals("052")){%>selected="selected"<%}%>>052</option>
	    <option value="053" <%if(model.getTel().substring(0,3).equals("053")){%>selected="selected"<%}%>>053</option>
	    <option value="054" <%if(model.getTel().substring(0,3).equals("054")){%>selected="selected"<%}%>>054</option>
	    <option value="055" <%if(model.getTel().substring(0,3).equals("055")){%>selected="selected"<%}%>>055</option>
	    <option value="061" <%if(model.getTel().substring(0,3).equals("061")){%>selected="selected"<%}%>>061</option>
	    <option value="062" <%if(model.getTel().substring(0,3).equals("062")){%>selected="selected"<%}%>>062</option>
	    <option value="063" <%if(model.getTel().substring(0,3).equals("063")){%>selected="selected"<%}%>>063</option>
	    <option value="064" <%if(model.getTel().substring(0,3).equals("064")){%>selected="selected"<%}%>>064</option>
    </select>
<%			
		}
	}
%>    
<%	
	if(!model.getTel().equals("")){
		if(model.getTel().startsWith("02")){
    		if(model.getTel().length() > 9){
%>
    <td class="ac bb1 h30"><input name="tel2" id="tel2" value="<%=model.getTel().substring(2,6) %>" title="전화번호" type="text" maxlength="4" style="width:70px;" />&nbsp;-&nbsp;   
    <td class="ac bb1 h30"><input name="tel3" id="tel3" value="<%=model.getTel().substring(7,model.getTel().length()) %>" title="전화번호" type="text" maxlength="4" style="width:70px;" />
<%
			}else{
%>
    <td class="ac bb1 h30"><input name="tel2" id="tel2" value="<%=model.getTel().substring(2,5) %>" title="전화번호" type="text" maxlength="4" style="width:70px;" />&nbsp;-&nbsp;   
    <td class="ac bb1 h30"><input name="tel3" id="tel3" value="<%=model.getTel().substring(5,model.getTel().length()) %>" title="전화번호" type="text" maxlength="4" style="width:70px;" />               
<%
   			}
		}else{
			if(model.getTel().length() > 10){               			
%>
    <td class="ac bb1 h30"><input name="tel2" id="tel2" value="<%=model.getTel().substring(3,7) %>" title="전화번호" type="text" maxlength="4" style="width:70px;" />&nbsp;-&nbsp;   
    <td class="ac bb1 h30"><input name="tel3" id="tel3" value="<%=model.getTel().substring(7,model.getTel().length()) %>" title="전화번호" type="text" maxlength="4" style="width:70px;" />			   
<%
			}else{
%>
               		
    <td class="ac bb1 h30"><input name="tel2" id="tel2" value="<%=model.getTel().substring(3,6) %>" title="전화번호" type="text" maxlength="4" style="width:70px;" />&nbsp;-&nbsp;   
    <td class="ac bb1 h30"><input name="tel3" id="tel3" value="<%=model.getTel().substring(6,model.getTel().length()) %>" title="전화번호" type="text" maxlength="4" style="width:70px;" />                      		
<% 
			}
    	}              
	} 
%>    
    <td class="ac bb1 h30">&nbsp;</td>
    </tr>
  <tr>
    <td class="ac fw bb1 h30 bg_g">* 휴대전화</td>
<%if(!model.getHp().equals("")){%>			
<td class=" bb1 h30 pl10"><select id="hp1" name="hp1" class="mg-l45" style="width:70px;">
<option value="010" <%if(model.getHp().substring(0,3).equals("010")){out.println("selected");} %>>010</option>
<option value="011" <%if(model.getHp().substring(0,3).equals("011")){out.println("selected");} %>>011</option>
<option value="016" <%if(model.getHp().substring(0,3).equals("016")){out.println("selected");} %>>016</option>
<option value="017" <%if(model.getHp().substring(0,3).equals("017")){out.println("selected");} %>>017</option>
<option value="018" <%if(model.getHp().substring(0,3).equals("018")){out.println("selected");} %>>018</option>
<option value="019" <%if(model.getHp().substring(0,3).equals("019")){out.println("selected");} %>>019</option>
</select>
&nbsp;-&nbsp;
<%		if(model.getHp().length() > 10){ %>   			  
<td class="ac bb1 h30"><input name="hp2" id="hp2" value="<%=model.getHp().substring(3,7) %>" title="핸드폰" type="text" maxlength="4" style="width:70px;" />&nbsp;-&nbsp;   
<td class="ac bb1 h30"><input name="hp3" id="hp3" value="<%=model.getHp().substring(7,model.getHp().length()) %>" title="핸드폰" type="text" maxlength="4" style="width:80px;" />
<%		}else{ %>
<td class="ac bb1 h30"><input name="hp2" id="hp2" value="<%=model.getHp().substring(3,6) %>" title="핸드폰" type="text" maxlength="4" style="width:70px;" />&nbsp;-&nbsp;   
<td class="ac bb1 h30"><input name="hp3" id="hp3" value="<%=model.getHp().substring(6,model.getHp().length()) %>" title="핸드폰" type="text" maxlength="4" style="width:80px;" />

<%		}
	}
%>     
    <td class="ac bb1 h30">&nbsp;</td>
    </tr>
  <tr>
    <td class="ac fw bb1 h30 bg_g">* 이메일</td>
    <td colspan="4" class=" bb1 h30 pl10">
<%
	if(!model.getEmail().equals("")){
		String email[] = model.getEmail().split("@");
		String tmpEmail = "";
		
		if (email[1].equals("hanmail.net")){
		 email[1] = "1";
		}else if (email[1].equals("naver.com")){
		 email[1] = "2";
		}else if (email[1].equals("yahoo.com")){
		 email[1] = "3";
		}else if (email[1].equals("hotmail.com")){
		 email[1] = "4";
		}else if (email[1].equals("nate.com")){
		 email[1] = "5";
		}else if (email[1].equals("paran.com")){
		 email[1] = "6";
		}else if (email[1].equals("dreamwiz.com")){
		 email[1] = "7";
		}else if (email[1].equals("empal.com")){
		 email[1] = "8";
		}else{
		 tmpEmail = email[1];
		 email[1] = "9";
		}
%>
		<input type="text" id="email1" name="email1" value="<%=email[0] %>" style="ime-mode:inactive;" />
		@
		<select style="width:100px;" id="email2" name="email2">
			<option value="">선택하세요.</option>
			<option value="" <%if(email[1].equals("9")){ %>selected="selected"<%} %>>직접입력</option>
			<option value="hanmail.net" <%if(email[1].equals("1")){ %>selected="selected"<%} %>>hanmail.net</option>
			<option value="naver.com" <%if(email[1].equals("2")){ %>selected="selected"<%} %>>naver.com</option>
			<option value="yahoo.com" <%if(email[1].equals("3")){ %>selected="selected"<%} %>>yahoo.com</option>
			<option value="hotmail.com" <%if(email[1].equals("4")){ %>selected="selected"<%} %>>hotmail.com</option>
			<option value="nate.com" <%if(email[1].equals("5")){ %>selected="selected"<%} %>>nate.com</option>
			<option value="paran.com" <%if(email[1].equals("6")){ %>selected="selected"<%} %>>paran.com</option>
			<option value="dreamwiz.com" <%if(email[1].equals("7")){ %>selected="selected"<%} %>>dreamwiz.com</option>
			<option value="empal.com" <%if(email[1].equals("8")){ %>selected="selected"<%} %>>empal.com</option>
		</select>&nbsp;
		<input type="text" id="email3" name="email3" value="<%=tmpEmail %>" style="width:60px;" />
<%}%>    
    </td>
    </tr>
</table>
  <div class="pt10"><span style="font-size:11px;">*입력 하신 소중한 정보는 서비스 향상과 고객지원을 위해 사용됩니다.</span></div>
<div class="pt25" align="center"><input type="image" src="/room/img/btn_finish.gif" width="47" height="26" /><a href="/room/main.jsp"><img src="/room/img/btn_cancle.gif" width="47" height="26" hspace="5" /></a></div>

    
    </div>
   </div>
</div>  
</form>
<!----------------가운데 끝---------------->



<!----------------오른쪽 시작---------------->  
<%@ include file="/room/common/right.jsp" %>  
<!----------------오른쪽 끝---------------->
</div>


<!-------------푸터영역----------> 
<%@ include file="/room/common/footer.jsp" %> 
<!-------------푸터영역----------> 
<script type="text/javascript">
swfobject.registerObject("FlashID");
</script>
</body>
</html>
